package com.wyh.service.serviceImpl.feemanagementserviceimpl;

import com.wyh.domain.po.feemanagementpo.Customers;
import com.wyh.mapper.feemanagementmapper.CustomerMapper;
import com.wyh.service.feemanagementservice.ICustomerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 客户表 服务实现类
 * </p>
 *
 * @author ggt
 * @since 2024-05-21
 */
@Service
public class CustomersServiceImpl extends ServiceImpl<CustomerMapper, Customers> implements ICustomerService {
    @Autowired
    private CustomerMapper customerMapper;
    @Override
    public Customers findByName(String name) {
        return customerMapper.findByName(name);
    }

    @Override
    public List<Integer> getCustomerIdByNameOrPhone(String nameOrPhone) {
        List<Customers> customers = lambdaQuery()
                .like(Customers::getName, nameOrPhone)
                .or()
                .like(Customers::getTelephone, nameOrPhone)
                .select(Customers::getId)
                .list();
        return  customers.stream()
                .map(Customers::getId)
                .collect(Collectors.toList());
    }
}
